import { request } from '../utils/request'
//登录
export const login = (data) => {
  return request.post('/admin/login', data)
}

//登出
export const logout = () => {
  return request.post('/admin/logout')
}

//小组列表
export const groupList = (data) => {
  return request.get('/group/listAll', data)
}

//增加小组成员
export function groupCreate (data) {
  return request.post('/group/create', data);
}
// export function createProd(data) {
//   return request.post('/product/create', data);
// }

//查询小组
export const groupSearch = (data) => {
  return request.get('/group/listByUser', data)
}

//编辑修改小组
export function updateGroup(form) {
  return request.post('/group/update/', form);
}

//删除小组
export function deleteGroup(groupId) {
  return request.post(`/group/delete?groupId=${groupId}`, groupId);
}
//查询小组信息(编辑小组成员调用)
export function getGroup(groupId){
  return request.get(`/group/list/${groupId}`);
}
//删除小组成员
export function deleteMember(groupId,memberId){
  return request.post(`/group/deleteMember/?groupId=${groupId}&userId=${memberId}`)
}
//添加小组成员
export function AddMember(groupId,memberId){
  return request.post(`/group/createMember/?groupId=${groupId}&userId=${memberId}`)
}
export function getStaffNoGroup(){
  return request.get('/group/staffNoGroup')
}


//货品列表
export const productList = (data) => {
  return request.get('/product/listAll', data)
}

//货品条件查询
export const productSearchList = (data) => {
  return request.get('/product/listPage', data)
}

//货品条件查询
export const getProductCategory = () => {
  return request.get('/productCategory/list/withChildren')
}

//获取商户信息

export const getShop = (params) => {
  return request.get('/shop/${id}', { params });
}





//添加店铺
export const createShop = (data) => {
  return request.post('shop/create', data)
}

//导入excel
export function importVerify(data) {
  return request.post('/shop/import/verify', data);
}

export function confirmImportInfo(id) {
  return request.post(`/shop/import/${id}`);
}

export function exportFailInfo(id) {
  return request.download(`/shop/export/fail/${id}`, null, "导入校验失败数据.xls");
}

//导入excel
export function importVerifyStaff(data) {
  return request.post('/group/import/verify', data);
}

export function confirmImportInfoStaff(id) {
  return request.post(`/group/import/${id}`);
}

export function exportFailInfoStaff(id) {
  return request.download(`/group/export/fail/${id}`, null, "导入校验失败数据.xls");
}

export const getShopByPage = (data) => {
  return request.get('/shop/listPage', data);
}
export const getStaffByPage = (data) => {
  return request.get('/group/staff', data);
}


const params = { pageNum: 1, pageSize: 5 }

export function fetchList(parentId, params) {
  // return request.get(`/menu/list/${parentId}`, { params });
  return request.get(`/menu/list/${parentId}`, params);
}

export function deleteMenu(id) {
  return request.post(`/menu/delete/${id}`);
}

export function createMenu(data) {
  return request.post('/menu/create', data);
}

export function updateMenu(id, data) {
  return request.post(`/menu/update/${id}`, data);
}

export function getMenu(id) {
  return request.get(`/menu/${id}`);
}

export function updateHidden(id, params) {
  // return request.post(`/menu/updateHidden/${id}`, null, { params });
  // 后端有点问题，已知返回400
  return request.post(`/menu/updateHidden/${id}`, params);
}

export function fetchTreeList() {
  return request.get('/menu/treeList');
}

//修改货品信息
export function updateProd(form) {
  return request.post(`/product/update/${form.value.id}`, form.value);
}

//删除货品
export function deleteProduct(id) {
  return request.post(`/product/delete/${id}`);
}

// export function getAdmin(id) {
//   return request.get(`/admin/${id}`);
// }
//获取用户信息
export function getAdmin(id) {
  return request.get(`/admin/${id}`);
}

const params1 = { pageNum: 1, pageSize: 5, keyword: '' }
export function getAdminList(params1) {
  // return request.get(`/menu/list/${parentId}`, { params });
  return request.get('/admin/list/', params1);
}

// 创建货品

export function createProd(data) {
  return request.post('/product/create', data);
}


//分页查询商品分类

export function getProductCategoryList(parentId, params) {
  // return request.get(`/menu/list/${parentId}`, { params });
  return request.get(`/productCategory/list/${parentId}`, params);
}

// 添加商品分类

export function createProductCategory(data) {
  return request.post('/productCategory/create', data);
}

//查询商品分类


//修改货品分类
export function updateProdCategory(form) {
  return request.post(`/productCategory/update/${form.value.id}`, form.value);
}

//删除货品分类
export function deleteProductCate(id) {
  return request.post(`/productCategory/delete/${id}`);
}

//创建货品分类
export function createProdCategory(data) {
  return request.post('/productCategory/create', data);
}

//订单模块


//获取订单列表
export function orderList(data) {
  return request.get('/order/list', data.value);
}

// 获取未被此订单分配的用户
export function getUnallocatedUsers(orderId, data) {
  return request.get(`/order/unallocated/${orderId}`, data);
}

// 更新订单状态
export function updateOrderStatus(orderId, status) {
  return request.put(`/order/status/${orderId}?status=${status}`);
}


// 删除订单中某员工
export function deleteAllocatedOrderUser(orderId, userId) {
  return request.delete(`/order/unallocated/${orderId}/${userId}` );
}






//获取指定id的订单基本信息

export function getProductDetail(orderId) {
  return request.get(`/order/list/${orderId}`);
}

//  获取订单分配工人信息/order/group/listAll/{orderId}
export function getWorker(orderId) {
  return request.get(`/order/group/listAll/${orderId}`);
}

//分配卸货小组成员
export function AllocateMembers(data) {
  return request.post('/order/allocGroupUsers', data);
}


//获取未分配的人员  /order/unallocated/{orderId}
export function getUnallocateMan(orderId) {
  return request.get(`/order/unallocated/${orderId}`);
}

//
export function getResource(id) {
  return request.get(`/resource/${id}`);
}

//获取订单的上传凭证

export function getOrderUnload(data) {
  return request.get('/order/listOrderUnload', data);
}

// 补充卸货凭证/order/updateUnload
export const getPictrueData = (data) => {
  return request.put('/order/updateUnload', data);
}

//线下支付信息

export const getOfflinePay = (data) => {
  return request.put('/order/offlinePay', data);
}

//根据店铺id查询店铺信息

export function getShopDetail(shopId) {
  return request.get(`/shop/${shopId}`);
}

//添加商铺用户
export function addShopUser(data) {
  return request.post('/user/wxRegist',data);
}
